/**
 * 服务器错误
 *
 */
import { Button, Empty } from "@nutui/nutui-react-taro";
import { View } from "@tarojs/components";
import { Refresh } from "@nutui/icons-react-taro";
import Taro from "@tarojs/taro";

function ServiceError({ setServiceError, serviceErrorMsg }) {
  return (
    <View>
      <Empty status="error" description={serviceErrorMsg || "加载失败/错误"} />
      <View className="text-center">
        <Button
          icon={<Refresh />}
          size="small"
          type="primary"
          onClick={() => {
            if (process.env.TARO_ENV === "h5") {
              window.location.reload();
            } else {
              const pages = Taro.getCurrentPages();
              const perpage = pages[pages.length - 1];
              perpage.onLoad();
            }
          }}
        >
          重试
        </Button>
      </View>
    </View>
  );
}

export default ServiceError;
